﻿//获取数据
function GetData(url, postInfo) {
    var obj = createAjaxObj();
    obj.open('POST', url, false);
    obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    obj.setRequestHeader('If-Modified-Since', '0');
    obj.send(postInfo);
    return unescape(obj.responseText);
}

//创建Ajax对象
function createAjaxObj() {
    if (window.ActiveXObject) {
        try {
            return new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e) {
            try {
                return new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e1) {
                return null;
            }
        }
    }
    else if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    else {
        return null;
    }
}

//获取URL参数
function GetParam(url, paramName) {
    var index = url.indexOf('?' + paramName + '=');
    if (index <= 0) {
        index = url.indexOf('&' + paramName + '=');
    }
    if (index <= 0) {
        return '';
    }

    var tempUrl = url.substring(index + 1);
    var nextIndex = tempUrl.indexOf('&');
    if (nextIndex > 0) {
        tempUrl = tempUrl.substring(0, nextIndex);
    }

    var result = tempUrl.replace(paramName + '=', '');
    return result;
}